package com.online.fund;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

public class JavascriptTest {

	public static void main(String[] args) {
		String fun = "var x = {'code': 123}";

		ScriptEngineManager sem = new ScriptEngineManager();
		ScriptEngine engine = sem.getEngineByExtension("js");
		try {
			engine.eval(fun);
		} catch (ScriptException ex) {
			ex.printStackTrace();
		}
//		System.out.println(engine.get("obj"));
		System.out.println(engine.get("x.code"));
	}

}
